/*
 * Copyright 2007 Jeffrey Palm
 */

import java.io.*;
import java.util.*;

class Config {

  private final static Config instance = new Config();
  public static Config getInstance() {return instance;}

  private final Properties props = new Properties();

  private final String file = ".ipodfork";
  Config() {
    try {
      File f = new File(file);
      if (f.exists()) {
        FileInputStream in = new FileInputStream(f);
        props.load(in);
        in.close();
      }
    } catch (Exception e) {e.printStackTrace();}
    Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
        public void run() {
          try {
            File f = new File(file);
            FileOutputStream out = new FileOutputStream(f);
            props.store(out,"properties");
            out.close();
          } catch (Exception e) {e.printStackTrace();}
        }
      }));
  }

  public String get(String key) {
    return props.getProperty(key);
  }

  public void set(String key, String val) {
    props.setProperty(key,val);
  }
  
}